package com.aiju.cash.core.api;

import com.aiju.app.config.ConfigManager;
import com.zhy.http.okhttp.OkHttpUtils;
import com.zhy.http.okhttp.callback.StringCallback;

/**
 * @author: 佐为
 * @date: 2016-12-07 15:03
 * @version: V1.0
 * @Description: 退款
 */
public class RefundApi {

    private String base = "https://trade.ecbao.cn";
    //private String base = "http://16794ui705.iok.la:29890";

    private String zfbpay = base + "/zfbpay/refund";
    private String cash = base + "/cash/refund";
    private String wxpay = base + "/wxpay/refund";

    private String token = ConfigManager.getInstance().getUser().getToken();
    /**
     * 支付宝退款
     */
    public void wxpayRefund(String storeId, String originalOutTradeNo,
                             String refundType, String totalFee, String refundFee,
                             String operatorId, String operatorName, String remark, String outRefundNo, StringCallback callback) {
        OkHttpUtils
                .post()
                .url(wxpay)
                .addParams("storeId", storeId)
                .addParams("originalOutTradeNo", originalOutTradeNo)
                .addParams("refundType", refundType)
                .addParams("totalFee", totalFee)
                .addParams("refundFee", refundFee)
                .addParams("operatorId", operatorId)
                .addParams("operatorName", operatorName)
                .addParams("remark", remark)
                .addParams("outRefundNo", outRefundNo)
                .addParams("token", token)
                .build()
                .execute(callback);
    }

    /**
     * 支付宝退款
     */
    public void zfbpayRefund(String storeId, String originalOutTradeNo,
                             String refundType, String totalFee, String refundFee,
                             String operatorId, String operatorName, String remark, String outRefundNo, StringCallback callback) {
        OkHttpUtils
                .post()
                .url(zfbpay)
                .addParams("storeId", storeId)
                .addParams("originalOutTradeNo", originalOutTradeNo)
                .addParams("refundType", refundType)
                .addParams("totalFee", totalFee)
                .addParams("refundFee", refundFee)
                .addParams("operatorId", operatorId)
                .addParams("operatorName", operatorName)
                .addParams("remark", remark)
                .addParams("outRefundNo", outRefundNo)
                .addParams("token", token)
                .build()
                .execute(callback);
    }

    /**
     * 现金退款
     */
    public void cashRefund(String storeId, String originalOutTradeNo,
                           String refundType, String totalFee, String refundFee,
                           String operatorId, String operatorName, String remark, String outRefundNo, StringCallback callback) {
        OkHttpUtils
                .post()
                .url(cash)
                .addParams("storeId", storeId)
                .addParams("originalOutTradeNo", originalOutTradeNo)
                .addParams("refundType", refundType)
                .addParams("totalFee", totalFee)
                .addParams("refundFee", refundFee)
                .addParams("operatorId", operatorId)
                .addParams("operatorName", operatorName)
                .addParams("remark", remark)
                .addParams("outRefundNo", outRefundNo)
                .addParams("token", token)
                .build()
                .execute(callback);
    }

}
